package org.niu.tree;

import java.util.ArrayList;
import java.util.List;

public class KthNode {
    List<Integer> list = new ArrayList<>();
    TreeNode KthNode(TreeNode pRoot, int k) {
        this.inOrder(pRoot);
        return new TreeNode(list.get(k-1));
    }
    void inOrder(TreeNode root){
        if(root == null) return;
        inOrder(root.left);
        list.add(root.val);
        inOrder(root.right);
    }
}
